package utils.xml;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;

public class XMLFileCleaner {
	public void clean(File file) {
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			StringBuffer clean_xml = new StringBuffer();
			String line;
			while((line = br.readLine())!=null) {
				line = line.replaceAll("amp;", "");
				line = line.replaceAll("&", "e");
				clean_xml.append(line);
			}
			br.close();
			
			PrintWriter out = new PrintWriter(new FileWriter(file));
			out.print(clean_xml.toString());
			out.close();
			
		}catch(Exception e) {
			e.printStackTrace();
		}	
	}
	
	public static void main(String[] args) {
		String line = "marcoamp lauraamp;";
		line = line.replaceAll("amp;", "");
		line = line.replaceAll("&", "e");
		System.out.println(line);
	}
	
}
